
# pip install pymysql
import pymysql

conn = pymysql.connect(
    host='127.0.0.1',
    user='root',
    passwd='12345678',
    port=3306,
    charset='utf8'
)

cursor = conn.cursor()
cursor.execute("select version()")
print(cursor.fetchone())

conn.close()